{# Auth redirect template for Dev Toolbar. Returned after successfully logging in to a requested organization. #}
{% load sentry_assets %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Sentry - Login Success</title>
    <link rel="icon" type="image/png" href="{% absolute_asset_url "sentry" "images/favicon.png" %}">
  </head>
  <body>
    <div>
      <p>You are logged in!</p>
      <p>This window will automatically close after 3 seconds. If not then check the console for errors.</p>
      <button type="button" id="close-popup">Close Popup</button>
    </div>

    {% script %}
    <script>
      // If the popup doesn't close, we can let people try to close it manually.
      document.getElementById('close-popup').addEventListener('click', () => {
        window.close();
      });

      if (window.opener) {
        window.opener.postMessage({
          source: 'sentry-toolbar',
          message: 'did-login',
        }, '*');

        setTimeout(() => {
          window.close();
        }, 3_000);
      }
    </script>
    {% endscript %}
  </body>
</html>
